cmake_minimum_required(VERSION 3.14)

project(dbus-demo LANGUAGES C CXX)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB REQUIRED glib-2.0 gobject-2.0 gio-unix-2.0)

file(GLOB ALL_ITEMS *.c)

foreach(ITEM ${ALL_ITEMS})
    get_filename_component(EXEUTABLE_NAME ${ITEM} NAME_WE)
    message(STATUS "add executable: ${EXEUTABLE_NAME}")
    add_executable(${EXEUTABLE_NAME} ${ITEM})
    target_include_directories(${EXEUTABLE_NAME} PRIVATE ${GLIB_INCLUDE_DIRS})
    target_link_libraries(${EXEUTABLE_NAME}  PRIVATE ${GLIB_LIBRARIES})    
endforeach()
